<#include "../header.html">
<script type="text/javascript">
	function changeUpdateType(obj){

		$("#updateMoney").val("0");
		$("#afterMoney").val($("#money").val());
	}
	function changeCurrencyType(obj){
		var currencyType = parseFloat($(obj).val());
		if(currencyType==1){
			$("#money").val($("#mlMoney").val());
		}else{
			$("#money").val($("#stampMoney").val());
		}
		$("#updateMoney").val("0");
		$("#afterMoney").val($("#money").val());

	}
	function isNumber(value) {         //验证是否为数字
		var patrn = /^(-)?\d+(\.\d+)?$/;
		if (patrn.exec(value) == null || value == "") {
			return false
		} else {
			return true
		}
	}
	function  upadteFunction(obj) {
		var updateType = $("#updateType").val();
		var updateMoney = parseFloat($(obj).val());
		if(isNumber(updateMoney)){
			if(updateType==2){
				var afterMoney = parseInt((parseFloat($("#money").val())*100+updateMoney*100))/100.0;
				$("#afterMoney").val(afterMoney);
				if (afterMoney<0) {
					$("#updateType").val("0");
					$("#afterMoney").val($("#money").val());
					$("#money").val($("#money").val());
					alert("修改后数据不能小于0");
				}
			}else{
				var afterMoney = parseInt((parseFloat($("#money").val())*100-updateMoney*100))/100.0;
				$("#afterMoney").val(afterMoney);
				if (afterMoney<0) {
					$("#updateType").val("0");
					$("#afterMoney").val($("#money").val());
					$("#money").val($("#money").val());
					alert("修改后数据不能小于0");
				}
			}
		}
	}
</script>
<div class="c_nav">
	<span>管理选项：</span>
	<a href="userAction.do?method=query">管理首页</a>
	<a href="javascript:location.reload()"> | [刷新页面]</a>
</div>
<div class="c_box bg_white">
<form id="addForm" name="addForm" action="userAction.do?method=saveMoneyOper" method="post">
	<div class="c_topic">修改用户资金</div>
	<input type="hidden" name="dataId" id="dataId" value="${user.id!}"/>
	<div class="c_form_3 c_form-label-8">
	<ul class="l_mb">
		<li>
			<span class="e_label e_label-required">用户帐号：</span>
			<span class="e_input">
				<input type="text" value="${user.account!}"/>
			</span>
		</li>
		<li>
			<span class="e_label e_label-required">用户名称：</span>
			<span class="e_input">
				<input type="text"  value="${user.userName!}" />
			</span>
		</li>
	</ul>
	<ul class="l_mb">
		<li>
			<span class="e_label e_label-required">货币类型：</span>
			<span class="e_select">
				<select name="currencyType" id="currencyType" onchange="changeCurrencyType(this);"  >
					<option value="1">马力</option>
					<option value="2">油票</option>
				</select>
			</span>
		</li>
		<li>
			<span class="e_label e_label-required">原有数量：</span>
			<span class="e_input">
				<input type="hidden" id="mlMoney" name="mlMoney" value="${user.mlMoney/100.0!}"/>
				<input type="hidden" id="stampMoney" name="stampMoney" value="${user.stampMoney/100.0!}"/>
				<input type="text" disabled id="money"  value="${user.mlMoney/100.0!}"/>
			</span>
		</li>

	</ul>
	<ul class="l_mb">
		<li>
			<span class="e_label e_label-required">修改类型：</span>
			<span class="e_select">
				<select name="updateType" id="updateType" onchange="changeUpdateType(this)"  >
					<option value="2">充值</option>
					<option value="3">减扣</option>
				</select>
			</span>
		</li>
	</ul>
	<ul class="l_mb">
		<li>
			<span class="e_label e_label-required">修改金额：</span>
			<span class="e_input">
			<input type="text" oninput="upadteFunction(this)" onpropertychange="upadteFunction(this)" name="updateMoney" id="updateMoney" desc="修改金额" nullable="no" maxlen="10" maxlength="10" datatype="numeric" value="0"/>
		</span>
		</li>
		<li>
			<span class="e_label e_label-required">修改后金额：</span>
			<span class="e_input">
			<input type="text" name="afterMoney" id="afterMoney" desc="修改后金额" readonly="readonly" nullable="no" maxlen="10" maxlength="10" datatype="numeric"  value="${user.mlMoney/100.0!}" />
			</span>
		</li>
	</ul>
	<ul class="c_form_3 c_form-label-8 l_mb">
		<li>
			<span class="e_label e_label-required">说明：</span>
			<span class="e_textarea">
			<textarea name="remark" id="remark" maxlen="255" maxlength="255" nullable="no"></textarea>
		</span>
		</li>
	</ul>
	</div>
	<div class="e_left">
		<button type="button" bind="" bindForm="addForm" class="e_btn-page">提交</button>
		<button type="reset" class="e_btn l_ml">重置</button>
	</div>
</form>
</div>
<#include "../footer.html">